package com.jwthhealth_pub.guardian.adapter;

/**
 * Created by yang on 2017/12/19.
 */


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.guardian.bean.GuardianBean;

import android.widget.TextView;


public class FootviewAdapter extends BaseFootviewAdapter<GuardianBean> implements View.OnClickListener{

        private ListItemView listItemView = null;

    private Callback mCallback;


    public interface Callback {
        public void click(View v);
    }

        public final class ListItemView {
            public LinearLayout gas_station_groupon_ll;
            public TextView tv_name;
            public TextView tv_mobile;
            public TextView tv_relieve;
        }

        public FootviewAdapter( Context mContext, ListView mListView,Callback callback) {
            super(mContext, mListView);
            mCallback = callback;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final GuardianBean object = (GuardianBean)getItem(position);
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.item_guardina_detail_groupon, parent, false);
                listItemView = new ListItemView();
                creatView(convertView, listItemView);
                convertView.setTag(listItemView);
            } else {
                listItemView = (ListItemView) convertView.getTag();
            }
            listItemView.tv_name.setText( object.name);
            listItemView.tv_mobile.setText( object.mobile);
            listItemView.tv_relieve.setOnClickListener(this);
            return convertView;
        }

        private void creatView(View rowView, ListItemView listItemView) {
            listItemView.gas_station_groupon_ll = (LinearLayout) rowView.findViewById(R.id.gas_station_groupon_ll);
            listItemView.tv_name = (TextView) rowView.findViewById(R.id.tv_name);
            listItemView.tv_mobile = (TextView) rowView.findViewById(R.id.tv_mobile);
            listItemView.tv_relieve = (TextView) rowView.findViewById(R.id.tv_relieve);
        }

    @Override
    public void onClick(View v) {
        mCallback.click(v);
    }

    }